home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / EmacsTeX / TeXfig / Source / TeXfigImageView.m < prev   
Encoding:
Text File  |  1995-06-12  |  1.5 KB  |  82 lines

  1.  
  2.  
  3. #import "TeXfigImageView.h"
  4.  
  5. @implementation TeXfigImageView
  6.  
  7.  
  8. static char textbuffer[1024]="blah I hope this works";
  9.  
  10.  
  11. -initFrame:(const NXRect*)r
  12. {
  13.     [super initFrame: r];
  14.  
  15.     // select a font for the text
  16.     font = [Font newFont: "Times-Bold"
  17.                         size:15
  18.                       matrix:NX_IDENTITYMATRIX];
  19.     imageid = 0;
  20.     pb = [Pasteboard new];
  21.  
  22.     return self;
  23. }
  24.  
  25. - newImage:(id) image
  26. {
  27.     imageid = image;
  28.     [self display];
  29.     return self;
  30. }
  31.  
  32.  
  33.  
  34. - drawSelf:(const NXRect *)rects :(int)rectCount
  35. {
  36.     NXRect aRect=rects[0];
  37.  
  38.     // if the image is null, then simplay clear
  39.     // the background, and write something    
  40.     // useful
  41.     if(imageid==0){
  42.         PSgsave();
  43.         NXSetColor(NX_COLORWHITE);
  44.         NXRectFill(rects);        
  45.         PSmoveto(0.0,0.0);
  46.         [font set];
  47.         PSshow("No image to display");
  48.         PSgrestore();
  49.     } else {
  50.         // clear what's there
  51.         NXPoint pt = {0.0, 0.0};   
  52.         PSgsave(); 
  53.         NXSetColor(NX_COLORWHITE);
  54.          NXRectFill(rects);
  55.             [imageid composite:NX_SOVER  toPoint:&pt];
  56.         PSgrestore();
  57.     }
  58.     return self;
  59. }
  60.  
  61. - copy: sender 
  62. {
  63.     NXStream *stream;
  64.     int length, maxlength=10000;
  65.     char *data;
  66.     id aList, anImageRep;
  67.     int i;
  68.  
  69.     aList = [imageid representationList];
  70.     anImageRep = nil;
  71.     for(i=0;i<[aList count]; i++)
  72.         if([[aList objectAt: i] class] == [NXEPSImageRep class])
  73.             anImageRep = [aList objectAt: i];
  74.  
  75.     if(anImageRep==nil) return self;
  76.     [pb declareTypes: &NXPostScriptPboardType num: 1 owner: sender];
  77.     [anImageRep getEPS: &data length: &length];
  78.     [pb writeType:NXPostScriptPboardType data:data length:length];
  79.     return self;
  80. }
  81. @end
  82.